package com.major.dawn.redission;


import org.redisson.Redisson;
import org.redisson.api.*;
import org.redisson.config.Config;
import org.redisson.jcache.JCache;

import java.util.concurrent.TimeUnit;

import static java.util.concurrent.TimeUnit.MILLISECONDS;

public class Action {

    public static void main(String[] args) throws InterruptedException {

        // 1. Create config object
        Config config = new Config();

        config.useSingleServer()
                // use "rediss://" for SSL connection
                .setAddress("redis://127.0.0.1:6379");


        // 2. Create Redisson instance

// Sync and Async API
        RedissonClient redisson = Redisson.create(config);


        RLock lock = redisson.getLock("1111");
        boolean locked = lock.isLocked();
        System.out.println(lock);
        if (locked) {
            lock.unlock();
        }

        System.out.println(locked);
        boolean b = lock.tryLock(3000, MILLISECONDS);
        System.out.println(b);


    }


}
